package com.zjgeport.zjgdanger.OnPortDynamics;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.zjgeport.zjgdanger.CommonActivity;
import com.zjgeport.zjgdanger.R;

public class AlarmInfoActivity extends CommonActivity {

    private TextView tankCodeTV,cargoTV,alarmTypeTV,alarmTimeTV,alarmInfoTV,titleTV,t1,t2,t3,t4,t5,t6;
    private LinearLayout alarmll;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_alarm_info);
        initCommonListener();
        initView();
    }

    private void initView()
    {
        titleTV = findTextViewById(R.id.title);
        titleTV.setText("储罐预警");
        tankCodeTV = findTextViewById(R.id.codeTV);
        tankCodeTV.setText(getIntent().getStringExtra("TANK_CODE"));
        cargoTV = findTextViewById(R.id.cargoTV);
        cargoTV.setText(getIntent().getStringExtra("CARGO_NAME"));
        alarmTypeTV = findTextViewById(R.id.alarmTypeTV);
        alarmll = (LinearLayout)findViewById(R.id.alarmLL);
        t1 = findTextViewById(R.id.t1);
        t2 = findTextViewById(R.id.t2);
        t3 = findTextViewById(R.id.t3);
        t4 = findTextViewById(R.id.t4);
        t5 = findTextViewById(R.id.t5);
        t6 = findTextViewById(R.id.t6);

        t1.setText(getIntent().getStringExtra("B_COMPANY"));
        t2.setText(getIntent().getStringExtra("CARGO_QUALITY"));
        t3.setText(getIntent().getStringExtra("TANK_TEMP"));
        t4.setText(getIntent().getStringExtra("CARGO_NUMBER"));
        t5.setText(getIntent().getStringExtra("CREATE_DATE"));
        String workState = getIntent().getStringExtra("WORK_STATE");
        if(getIntent().getStringExtra("WORK_STATE").equals("S"))
        {
            t6.setText("静止");
        }
        else if(getIntent().getStringExtra("WORK_STATE").equals("I"))
        {
            t6.setText("入库");
        }

        else if(getIntent().getStringExtra("WORK_STATE").equals("O"))
        {
            t6.setText("出库");
        }

        if (getIntent().getStringExtra("IS_ALARM").equals("0"))
        {
            alarmll.setVisibility(View.GONE);
        }
        else{
            if(getIntent().getStringExtra("CARGO_NAME").equals("E201610200001364"))
            {
                alarmTypeTV.setText("超范围");
            }
            else  if(getIntent().getStringExtra("CARGO_NAME").equals("E201611230004201")){

                alarmTypeTV.setText("作业未申报");
            }
            alarmTimeTV = findTextViewById(R.id.alarmTimeTV);
            alarmTimeTV.setText(getIntent().getStringExtra("ALARM_DATE"));
            alarmInfoTV = findTextViewById(R.id.alarmInfoTV);
            String alarmInfo = getIntent().getStringExtra("ALARM_INFO");
            alarmInfoTV.setText(alarmInfo);
        }

    }
}
